package com.dfrz.stockMarket.web;  

import java.io.IOException;  
import javax.servlet.ServletException;  
import javax.servlet.http.HttpServlet;  
import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;

import com.dfrz.stockMarket.bean.MessageBean;
import com.dfrz.stockMarket.bean.UserBean;
import com.dfrz.stockMarket.cons.Constants;
import com.dfrz.stockMarket.service.UserService;  
   
   
 public class Check extends BaseController {  
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
       //解决返回中文乱码问题  
    	System.out.println("开心");

		String path = request.getContextPath();
       response.setCharacterEncoding("utf-8");  
       String user = request.getParameter("username"); 
       String pwd = request.getParameter("userpwd");
       //解决接收中文乱码问题
       user = new String(user.getBytes("iso-8859-1"),"gb2312");  
       System.out.println("user:"+user);  
       System.out.println("pwd:"+pwd); 
       String msg = null;  
			try {
				MessageBean mb = UserService.getUserBeanByName(user);
				UserBean userbean=(UserBean)mb.getMsg();
				String uname=userbean.getUserInfoModel().getUserName();
				String upwd=userbean.getUserInfoModel().getUserPassWord();
				  System.out.println("uname:"+uname);  
			       System.out.println("upwd:"+upwd);
			       if(uname==null)  
			       {  
			           msg = "用户名不存在!";  
			       }else{
			    	   if(pwd.equals(upwd)) 
			       {  
			           msg = "成功!"; 
			          
			       } else{
			    	   msg = "密码错误!"; 
			       }
			       }
			       System.out.println(msg);
				
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		
		
		
       /* */
       
        
    }   
    
    
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
       doGet(request,response);  
    }                
}  